﻿using Common.Json;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Aliyun
{
    internal static class Utils
    {
        public static string ToJson(object obj)
        {
            return JsonConvert.SerializeObject(obj, GetJsonSettings());
        }

        private static JsonSerializerSettings jss;
        public static JsonSerializerSettings GetJsonSettings()
        {
            if (jss == null)
            {
                jss = new JsonSerializerSettings();
                jss.Converters.Add(new EnumToStringConverter());
                jss.Converters.Add(new DateTimeFormatConverter());
            }
            return jss;
        }
    }
}
